// 文章相关的接口 article.js
import request from "@/util/http";

// 获取分类信息
export const getCategories = () => {
    return request({
        url: '/admin/categories',
        method: 'get'
    });
};

// 获取文章列表
// 获取文章列表
export const getArticles = (tag = '全部', currentPage = 1, searchTitle = '', startDate = '', endDate = '') => {
    return request({
        url: '/admin/articles',
        method: 'get',
        params: {
            tag,
            page: currentPage,
            search_title: searchTitle,
            start_date: startDate,
            end_date: endDate
        }
    });
};


// 添加文章
export const addArticle = (data) => {
    return request({
        url: '/admin/articles',
        method: 'post',
        data
    });
};

// 更新文章
export const updateArticle = (id, data) => {
    return request({
        url: `/admin/articles/${id}`,
        method: 'put',
        data
    });
};

// 删除文章
export const deleteArticle = (id) => {
    return request({
        url: `/admin/articles/${id}`,
        method: 'delete'
    });
};